/********************************************************************************
 *      Copyright:  (C) 2022 Zhang Changxing<ZhangChangxingVIP@163.com>
 *                  All rights reserved.
 *
 *       Filename:  socket.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(04/13/2022)
 *         Author:  Zhang Changxing <ZhangChangxingVIP@163.com>
 *      ChangeLog:  1, Release initial version on "04/13/2022 01:27:29 AM"
 *                 
 ********************************************************************************/

#ifndef  _SOCKET_H_
#define  _SOCKET_H_

#include <sys/socket.h>
#include <linux/tcp.h>
#include <getopt.h>
//#include <netinet/in.h>
//#include <netinet/ip.h>
#include "main.h"

/*
 *   description:   Initialize the socket to connect to the server
 *          args:
 *                  $sockfd:    Store the variable address of the socket file descriptor
 *                  $port:      Port number of the server
 *                  $ip_addr:   IP address of the server
 *  return value:   <0: failure,    =0:ok 
 */
int connect_socket(int *sockfd, int port, char *ip_addr);

/*
 *   description:   Sends data to the server
 *          args:   $sockfd:    The socket file descriptor for which a connection has been established
 *                  $pack_info: The packet structure that needs to be sent to the server
 *  return value:   <0: failure,    =0:ok 
 */
int sendata(int sockfd, pack_info_t pack_info);

/*
 *   description:   Check socket connection status in real time
 *          args:   $sockfd:    The socket file descriptor for which a connection has been established
 *  return value:   <0: failure,    =0:ok 
 */
int get_sock_status(int sockfd);

#endif   /* ----- #ifndef _SOCKET_H_  ----- */

